import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'Index',
    component: () => import('../views/Index.vue'),
    meta: {
      authorization: true,
    },
    children: [
      {
        path: '',
        name: 'Category',
        component: () => import('../views/index/Category'),
        meta: {
          authorization: true,
        }
      },
      {
        path: '/task',
        name: 'Task',
        component: () => import('../views/index/Task'),
        meta: {
          authorization: true
        },
        children: [
          {
            path: '',
            name: 'Subject',
            component: () => import('../views/index/task/Subject'),
            meta: {
              authorization: true,
              title: "任务"
            },
          },
          {
            path: '/detail',
            name: 'Detail',
            component: () => import('../views/index/task/Detail'),
            meta: {
              authorization: true,
              title: "答题"
            },
          }
        ],
      },
      {
        path: '/personal',
        name: 'Personal',
        component: () => import('../views/index/Personal.vue'),
        meta: {
          authorization: true,
          title: '个人中心',
        },
      },
      {
        path: '/rank',
        name: 'Rank',
        component: () => import('../views/Rank.vue'),
        meta: {
          authorization: true,
          title: '排行榜',
        },
      },
    ],
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue'),
    meta: {
      title: '登录',
    },
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue'),
    meta: {
      title: '注册',
    },
  },
  {
    path: '/bind',
    name: 'Bind',
    component: () => import('../views/Bind.vue'),
    meta: {
      title: '完成注册',
    },
  },
  {
    path: '/forgot',
    name: 'Forgot',
    component: () => import('../views/Forgot.vue'),
    meta: {
      title: '忘记密码',
    },
  },
  {
    path: '/reset',
    name: 'ResetPassword',
    component: () => import('../views/ResetPassword.vue'),
    meta: {
      title: '重置密码',
    },
  },
];

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes,
});

export default router;
